#include "Q9_1.h"

Date::_Date()
{
	day = 1;
	month = 1;
	year = 1;
}
Date::_Date(int d, int m, int y)
{
	day = d;
	month =m;
	year = y;
}

void Date::Print()
{
	cout<<Date::day<<"/"<<Date::month<<"/"<<Date::year<<endl;
}

int People::m_count = 0;
int Staff::m_count = 0;
int Student::m_count = 0;
int Teacher::m_count = 0;

People::People(int id, Date date, char *name)
{
	m_count++;
	this->m_date = date;
	this->m_idcode = id;
	this->m_name = name;
}

People::People(People *p)
{
	m_count++;
	this->m_date = p->GetDate();
	this->m_idcode = p->GetID();
	this->m_name = p->GetName();
}

People::~People()
{
	m_count--;
}

void People::PrintInfo()
{
	cout<<"ID code: "<<m_name<<endl;
	cout<<"Name: "<<m_name<<endl;
	cout<<"Birthday: ";
	m_date.Print();
}

Staff::Staff(int id, Date date, char *name, int deparmentID, Date joinDate, int level)
{
	People::People(id, date, name);
	m_count++;
	this->m_DeparmentID = deparmentID;
	this->m_JoinDate = joinDate;
	this->m_Level = level;
}

Staff::Staff(Staff *staff)
{
	People::People((People*)staff);
	m_count++;
	this->m_DeparmentID = staff->GetDeparment();
	this->m_JoinDate = staff->GetJoinDate();
	this->m_Level = staff->GetLevel();
}

Staff::~Staff()
{
	m_count++;
}

void Staff::PrintInfo()
{
	People::PrintInfo();
	cout<<"Deparment ID: "<<m_DeparmentID<<endl;
	cout<<"Join Date: ";
	m_JoinDate.Print();
	cout<<"Level: "<<m_Level<<endl;
}

Student::Student(int id, Date date, char *name, int grade, int numOfProject, float *scoreEachProject)
{
	People::People(id, date, name);
	m_count++;
	this->m_Grade = grade;
	this->m_NumOfProject = numOfProject;
	this->m_ScoreEachProject = scoreEachProject;
}

Student::Student(Student *student)
{
	People::People((People*)student);
	m_count++;
	this->m_Grade = student->GetGrade();
	this->m_NumOfProject = student->GetNumOfProject();
	float *temp = student->GetScoreEachProject();
	this->m_ScoreEachProject = new float[m_NumOfProject];
	for(int i=0; i<m_NumOfProject; i++)
		m_ScoreEachProject[i] = temp[i];
}

Student::~Student()
{
	m_count--;
}

void Student::PrintInfo()
{
	People::PrintInfo();
	cout<<"Grade: "<<m_Grade<<endl;
	cout<<"Number of project: "<<m_NumOfProject<<endl;
	cout<<"Avg score of project: "<<GetAVGScores()<<endl;
}

float Student::AvgScore()
{
	float sum = 0;
	for(int i=0; i<m_NumOfProject; i++)
		sum += m_ScoreEachProject[i];
	return sum/m_NumOfProject;
}

float Student::GetAVGScores()
{
	return AvgScore();
}

//Teacher::Teacher(int id, Date date, char *name, int deparmentID, Date joinDate, int level, int classID, Subject subject, SecondSubject subjectND)
//{
//	m_count++;
//	this->m_Class = classID;
//	this->m_Subject = subject;
//	this->m_SecondSubject = subjectND;
//}

Teacher::Teacher(Teacher *teacher)
{
	Staff::Staff((Staff*)teacher);
	m_count++;
	this->m_Class = teacher->GetClass();
	this->m_Subject = teacher->GetSubject();
	this->m_SecondSubject = teacher->GetSecondSubject();
}

Teacher::~Teacher()
{
	m_count--;
}

void Teacher::PrintInfo()
{
	Staff::PrintInfo();
	cout<<"Class ID: "<<m_Class<<endl;
	cout<<"Subject: "<<m_Subject<<endl;
	cout<<"SecondSubject: "<<m_SecondSubject<<endl;
}

Node::Node()
{
	m_Data = NULL;
	m_Next = NULL;
}

Node::Node(Node *node)
{
	m_Next = node->m_Next;
}

void Node::Add(Node *node)
{
	Node::m_Next = node;
}